package it.amicosmanettone.finance.stocky.bean;

import java.io.Serializable;

import android.util.Log;

public class SingleStockBean implements Serializable {

	private String stockCurrency = "";// Valuta originale di questa stock
	private String stockMarket = "";// Mercato di questa stock ad esempio NASDAQ
	private String stockSymbol = "N/A";// Stock symbol
	private String stockName = "NO_NAME";// Stock name
	private double stockValue = -1L;// Valore singola azione...
	private long stockNumbers = 0L;// Numero di azioni di questo tipo...
	private double totalStockValue = 0L;// Aggiornato in automatico se si fa set
										// di stockNumbers o stockValue...
	private double stockTrend=1;
	
	
	public SingleStockBean(String stockSymbol, String stockName,
			String stockMarket, String stockCurrency) {
		super();
		this.stockCurrency = stockCurrency;
		this.stockMarket = stockMarket;
		this.stockSymbol = stockSymbol;
		this.stockName = stockName;
	}// End constructor...

	public SingleStockBean(String name) {
		// TODO Auto-generated constructor stub
		this.stockName = name;
	}

	public String getStockCurrency() {
		return stockCurrency;
	}

	public void setStockCurrency(String stockCurrency) {
		this.stockCurrency = stockCurrency;
	}

	public String getStockMarket() {
		return stockMarket;
	}

	public void setStockMarket(String stockMarket) {
		this.stockMarket = stockMarket;
	}

	public String getStockName() {
		return stockName;
	}

	public void setStockName(String stockName) {
		this.stockName = stockName;
	}

	public String getStockSymbol() {
		return stockSymbol;
	}

	public void setStockSymbol(String stockSymbol) {
		this.stockSymbol = stockSymbol;
	}

	public long getStockNumbers() {
		return stockNumbers;
	}

	public void setStockNumbers(long stockNumbers) {
		this.stockNumbers = stockNumbers;
		totalStockValue = stockNumbers * stockValue;
	}

	public double getStockValue() {
		double val=0;
		if(this.stockValue >0){
			val=(int) Math.round(this.stockValue * 100) / (double) 100;
		}
		return val;
	}

	public void setStockValue(double stockValue) {
		this.stockValue = stockValue;
		totalStockValue = stockValue * stockNumbers;
	}

	public double getTotalStockValue() {
		Log.v("UPDATE", "TotalStockValue: " + this.totalStockValue);
		double val=0;
		if(this.totalStockValue >0){
			val=(int) Math.round(this.totalStockValue * 100) / (double) 100;
		}
		return (val);
		
	}

	
	
	
	public double getStockTrend() {
		return stockTrend;
	}

	public void setStockTrend(double stockTrend) {
		this.stockTrend = stockTrend;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		SingleStockBean objBean = (SingleStockBean) obj;
		if (obj == null
				|| !(this.getStockSymbol().equalsIgnoreCase(objBean
						.getStockSymbol()))) {
			return false;
		}
		return (false);
	}

}
